#include "anry-stock-config.h"
#include "anry-stock-retrieve-panel.h"

BEGIN_EVENT_TABLE(AnryStockRetrievePanel, wxPanel)
    EVT_BUTTON(ID_BTN_RETRIEVE_DATA,  AnryStockRetrievePanel::OnRetreiveData)
END_EVENT_TABLE()

AnryStockRetrievePanel::AnryStockRetrievePanel(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
	: wxPanel(parent, id, pos, size, style, name)
{
	// store statice text size
	wxRect tmpRect;
	
	// setup retrieve year
	m_p_label_retrieve_year = new wxStaticText( this, wxID_ANY, wxT("Year: "),
		wxPoint(PANEL_BORDER_SIZE, PANEL_BORDER_SIZE) );
	tmpRect = m_p_label_retrieve_year->GetRect();
	m_p_text_retrieve_year = new wxTextCtrl( this, wxID_ANY, "",
		wxPoint(tmpRect.GetRight(), tmpRect.GetTop()-PANEL_TEXT_CTRL_Y_EXPAND_SIZE/2),
		wxSize(50, tmpRect.GetHeight()+PANEL_TEXT_CTRL_Y_EXPAND_SIZE) );
	tmpRect = m_p_text_retrieve_year->GetRect();

	// setup retrieve season
	m_p_label_retrieve_season = new wxStaticText( this, wxID_ANY, wxT("Season: "),
		wxPoint(tmpRect.GetRight()+PANEL_CTRL_SEPARATE_SIZE, PANEL_BORDER_SIZE) );
	tmpRect = m_p_label_retrieve_season->GetRect();
	m_p_text_retrieve_season = new wxTextCtrl( this, wxID_ANY, "",
		wxPoint(tmpRect.GetRight(), tmpRect.GetTop()-PANEL_TEXT_CTRL_Y_EXPAND_SIZE/2),
		wxSize(30, tmpRect.GetHeight()+PANEL_TEXT_CTRL_Y_EXPAND_SIZE) );
	tmpRect = m_p_text_retrieve_season->GetRect();
	
	// button
    m_p_btn_retrieve_data = new wxButton( this, ID_BTN_RETRIEVE_DATA, wxT("Retrieve"),
		wxPoint(tmpRect.GetRight()+PANEL_CTRL_SEPARATE_SIZE, tmpRect.GetTop()),
		wxSize(100, tmpRect.GetHeight()) );
}

void AnryStockRetrievePanel::OnRetreiveData(wxCommandEvent& WXUNUSED(event))
{
    wxMessageBox( _("This is a wxWidgets Hello world sample"),
                  _("About Hello World"),
                  wxOK | wxICON_INFORMATION, this );
}
